<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/views/include/taglib.jsp" %>

<!DOCTYPE html> <!--[if IE 8]> <html lang="zh" class="ie8 no-js"> <![endif]--> <!--[if IE 9]> <html lang="zh" class="ie9 no-js"> <![endif]--> <!--[if !IE]><!-->
<html lang="zh">
<!--<![endif]-->

<!-- BEGIN HEAD -->
<head>
    <title>流程管理</title>
    <meta name="decorator" content="default"/>
</head>
<!-- END HEAD -->

<body class="page-container-bg-solid page-header-fixed page-sidebar-closed-hide-logo">
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN SIDEBAR -->
    <div class="page-sidebar-wrapper">
        <!-- BEGIN SIDEBAR -->
        <div class="page-sidebar navbar-collapse collapse">
            <!-- BEGIN SIDEBAR MENU -->
            <ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
                <li class="heading">
                    <h3 class="uppercase">流程管理</h3>
                </li>
                <t:menu menu="${fns:getTopMenu()}" parentName="在线办公" currentName="流程管理"></t:menu>
            </ul>
            <!-- END SIDEBAR MENU -->
        </div>
        <!-- END SIDEBAR -->
    </div>

    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <!-- BEGIN CONTENT BODY -->
        <div class="page-content" style="padding-top: 0;">
            <!-- BEGIN PAGE HEADER-->
            <!-- BEGIN TABLE -->
            <div class="row">
                <div class="col-md-12">
                    <div class="pull-left">
                            <table:addRow url="${ctx}/act/model/create"  title="新建模型"></table:addRow><!-- 增加按钮 -->
                            <table:delRow url="${ctx}/act/model/deleteAll" id="contentTable"></table:delRow><!-- 删除按钮 -->
                        <button class="btn btn-default btn-sm" onclick="sortOrRefresh()"><i class="fa fa-repeat"></i> 刷新</button>

                    </div>
                    <div class="pull-right">
                        <button  class="btn btn-primary btn-sm" onclick="search()" ><i class="fa fa-search"></i> 查询</button>
                        <button  class="btn btn-primary btn-sm" onclick="reset()" ><i class="fa fa-refresh"></i> 重置</button>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="table-scrollable">
                        <table id="contentTable" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr style="white-space: nowrap;">
                                <th>流程分类</th>
                                <th>模型ID</th>
                                <th>模型标识</th>
                                <th>模型名称</th>
                                <th>版本号</th>
                                <th>创建时间</th>
                                <th>最后更新时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${page.list}" var="model">
                                <tr class="active">
                                    <td>
                                        <a href="javascript:updateCategory('${model.id}', '${model.category}');">${fns:getDictLabel(model.category,'act_category','无分类')}</a>
                                    </td>
                                    <td>${model.id}</td>
                                    <td>${model.key}</td>
                                    <td>${model.name}</td>
                                    <td><b title='流程版本号'>V: ${model.version}</b></td>
                                    <td><fmt:formatDate value="${model.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                    <td><fmt:formatDate value="${model.lastUpdateTime}"
                                                        pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                    <td>
                                        <shiro:hasPermission name="act:model:edit">
                                        <a href="${pageContext.request.contextPath}/act/process-editor/modeler.jsp?modelId=${model.id}"
                                           target="_blank">在线设计</a>
                                        </shiro:hasPermission>
                                        <a href="${ctx}/act/model/deploy?id=${model.id}"
                                           onclick="return Custom.initBootBoxConfirm('确认要部署该模型吗？', this.href)">部署</a>
                                        <a href="${ctx}/act/model/export?id=${model.id}" target="_blank">导出</a>
                                        <a href="${ctx}/act/model/delete?id=${model.id}"
                                           onclick="return Custom.initBootBoxConfirm('确认要删除该模型吗？', this.href)">删除</a>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>

                    </div>
                    <div>${page}</div>
                </div>
            </div>
            <!-- END TABLE -->
        </div>
        <!-- END CONTENT BODY -->
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->

<!-- BEGIN MODAL -->
<div class="modal fade modal-scroll in" id="categoryModal" role="basic" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form id="categoryForm" action="${ctx}/act/model/updateCategory" method="post" class="form-horizontal"
                  onsubmit="Custom.initStartPageBlockUI();">
                <input id="categoryBoxId" type="hidden" name="id" value=""/>
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">设置分类</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group form-md-line-input">
                        <div style="padding-left:20px; padding-right: 20px;">
                            <select id="categoryBoxCategory" name="category" class="form-control">
                                <c:forEach items="${fns:getDictList('act_category')}" var="dict">
                                    <option value="${dict.value}">${dict.label}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input id="categorySubmit" class="btn blue" type="submit" value="  保  存  "/>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- END MODAL -->

<%@include file="/views/include/foot.jsp" %>
<script type="text/javascript">
    function page(n, s) {
        Custom.initStartPageBlockUI();
        location = '${ctx}/act/model/?pageNo=' + n + '&pageSize=' + s;
    }

    function updateCategory(id, category) {
        $("#categoryBoxId").val(id);
        $("#categoryBoxCategory").val(category);
        $("#categoryModal").modal("show");
    }
</script>
</body>
</html>